import { BasicFetchResult } from '../../model/baseModel';
import { defHttp } from '@/utils/http/axios';
const Api = '/codeGenerate';
const ConfigApi = '/sysCodeGenerateConfig';
export const page = (params?: any) =>
  defHttp.get<BasicFetchResult<any>>({ url: Api + '/page', params });
export const add = (params?: any) =>
  defHttp.post({ url: Api + '/add', params });
export const edit = (params?: any) =>
  defHttp.post({ url: Api + '/edit', params });
export const editColumns = (params?: any) =>
  defHttp.post({ url: Api + '/editColumns', params });

export const del = (ids: string[]) =>
  defHttp.post({ url: Api + '/delete', params: ids });
export const getColumnsList = (params?: any) =>
  defHttp.get<BasicFetchResult<any>>({ url: ConfigApi, params });
export const editColumnsList = (params?: any) =>
  defHttp.post<BasicFetchResult<any>>({ url: ConfigApi, params });
export const runLocalCodeGen = (id: string) =>
  defHttp.post({ url: Api + '/runLocal', params: { id } });
export const preview = (id: string) =>
  defHttp.get<BasicFetchResult<any[]>>({
    url: `${Api}/preview`,
    params: { id },
  });

export const runDownCodeGen = (id: string) =>
  defHttp.get(
    { responseType: 'blob', url: Api + '/runDown', params: { id } },
    { isReturnNativeResponse: true }
  );
